import { createStore } from "vuex";

const store = createStore({
  state: {
    msg: "hello",
    count: 100,
  },
  getters: {
    doubleCount(state, getters) {
      return state.count * 2;
    },
  },
  mutations: {
    add(state, payload) {
      state.count++;
    },
    minus(state) {
      state.count--;
    },
  },
  actions: {
    asyncMinus(context) {
      setTimeout(() => {
        context.commit("minus");
      }, 1000);
    },
  },
  modules: {},
});

export default store;
